from fastapi import APIRouter, Depends, Query

from src.base.beans import Rest
from src.config.auth import auth_depend
from src.config.log import log_depend
from src.dao.sys_dept_dao import get_dept_and_child_list
from src.domain.sys_dept import SysDept

router = APIRouter(prefix='/dept', dependencies=[Depends(auth_depend), Depends(log_depend)], tags=["部门管理"])


@router.get("/dept-and-childes-by-id", summary="查询本部门以及子部门22", )
async def get_dept_and_childes_by_id(dept_id: int = Query(default=0)) -> Rest[list[SysDept]]:
    depts = get_dept_and_child_list([dept_id])
    return Rest.ok(depts)
